//
//  HomeWithOUTViewController.m
//  shanHaiHuiApp
//
//  Created by DS on 2018/3/12.
//  Copyright © 2018年 徐双. All rights reserved.
//

#import "HomeWithOUTViewController.h"

@interface HomeWithOUTViewController ()<UITextFieldDelegate>

//空白页
Strong UIView * blankView;
Strong UITextField * textField;
Strong UIView * headerView;
Strong UIButton * bottomBtn;

@end

@implementation HomeWithOUTViewController

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    [self NavColor];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"yingyeyuan1"] style:UIBarButtonItemStylePlain target:self action:@selector(leftBarButtonItemClick)];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.textField];
    [self.view addSubview:self.blankView];
    [self.view addSubview:self.bottomBtn];
}

// 导航颜色
- (void)NavColor{
    
    UINavigationBar * bar = self.navigationController.navigationBar;
    UIImage *bgImage = [UIImage imageWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 64) WihtColor:getColor(navColor) alphe:1.0];
    [bar setBackgroundImage:bgImage forBarMetrics:UIBarMetricsDefault];
    
    
    [bar setShadowImage:[UIImage imageWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 0.1) WihtColor:[UIColor blackColor] alphe:1.0]];
    
}


//输入框
- (UITextField *)textField{
    if (!_textField) {
        _textField  = [[UITextField alloc]initWithFrame:CGRectMake(UNIT_WIDTH(10), UNIT_WIDTH(15), SCREEN_WIDTH - UNIT_WIDTH(30), UNIT_HEIGHT(25))];
        _textField.font = DEF_FontSize_14;
        _textField.placeholder = @"请录入商品编号、商品名称、商品产地";
        _textField.layer.masksToBounds = YES;
        _textField.layer.cornerRadius = 5;
        _textField.returnKeyType = UIReturnKeySearch;
        _textField.leftView = ({
            UIImageView *leftImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 30, 20)];
            leftImageView.contentMode = UIViewContentModeScaleAspectFit;
            leftImageView.image = [UIImage imageNamed:@"sousuo_icon"];
            leftImageView;
        });
        _textField.leftViewMode = UITextFieldViewModeAlways;
        _textField.backgroundColor = getColor(@"F0F0F0");
        _textField.delegate = self;
        _textField.clearButtonMode = UITextFieldViewModeAlways;
    }
    return _textField;
}

-(UIView *)blankView{
    if (!_blankView) {
        _blankView = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_textField.frame) + UNIT_HEIGHT(10), SCREEN_WIDTH, SCREEN_HEIGHT - height64 - UNIT_HEIGHT(45) - UNIT_HEIGHT(49))];
        UIImageView * blankImage = [UIImageView new];
        blankImage.image = [UIImage imageNamed:@"yichang"];
        blankImage.contentMode = UIViewContentModeScaleAspectFit;
        
        UILabel * blankLabel = [[UILabel alloc] init];
        blankLabel.text = @"网络连接异常";
        blankLabel.font = DEF_FontSize_18;
        blankLabel.textColor = getColor(@"666666");
        blankLabel.textAlignment = NSTextAlignmentCenter;
        
        [_blankView sd_addSubviews:@[blankImage,blankLabel]];
        
        [blankImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(UNIT_HEIGHT(114));
            make.centerX.mas_equalTo(_blankView.mas_centerX);
            make.height.mas_equalTo(UNIT_HEIGHT(158));
            make.width.mas_equalTo(UNIT_WIDTH(165));
        }];
        
        [blankLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(blankImage.mas_bottom).offset(UNIT_HEIGHT(15));
            make.centerX.mas_equalTo(_blankView.mas_centerX);
            make.height.mas_equalTo(UNIT_HEIGHT(30));
            make.width.mas_equalTo(UNIT_WIDTH(150));
        }];
        
    }
    return _blankView;
}

- (UIButton *)bottomBtn{
    
    if (!_bottomBtn) {
        _bottomBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_blankView.frame), SCREEN_WIDTH, UNIT_HEIGHT(49))];
        [_bottomBtn setTitle:@"请挑选商品" forState:UIControlStateNormal];
        [_bottomBtn setBackgroundColor:getColor(@"949494")];
        [_bottomBtn setTitleColor:getColor(@"323232") forState:UIControlStateNormal];
        _bottomBtn.enabled = NO;
        _bottomBtn.titleLabel.font = DEF_FontSize_14;
        
    }
    return _bottomBtn;
}

@end
